package com.shape.sdk;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by ouzhiyin on 18/01/2018.
 */

public class Course implements Serializable, Cloneable {
  int scheduleId;
  String name;
  long startTime;
  long duration;
  int type;
  List<VideoUnit> playList;
  Course() {}

  public int getScheduleId() {
    return scheduleId;
  }

  public String getName() {
    if (name == null) {
      return "";
    }
    return name;
  }

  public long getStartTime() {
    return startTime;
  }

  public long getDuration() {
    return duration;
  }

  public int getType() {
    return type;
  }

  public List<VideoUnit> getPlayList() {
    return playList;
  }

  public static class VideoUnit implements Serializable, Cloneable {
    String name;
    String video;
    String audio;
    long videoDuration;
    boolean goNext;
    VideoUnit() {

    }
    public String getName() {return name;}
    public String getVideo() {
      return video;
    }
    public String getAudio() {
      return audio;
    }
    public long getVideDuration() {
      return videoDuration;
    }
    public boolean getGoNext() {
      return goNext;
    }
    public VideoUnit clone() {
      VideoUnit unit;
      try {
        unit = (VideoUnit) super.clone();
      } catch (CloneNotSupportedException e) {
        unit = new VideoUnit();
      }
      unit.video = this.video;
      unit.audio = this.audio;
      unit.videoDuration = this.videoDuration;
      unit.goNext = this.goNext;
      return unit;
    }
  }

  public Course clone() {
    Course course;
    try {
      course = (Course) super.clone();
    } catch (CloneNotSupportedException e) {
      course = new Course();
    }
    course.scheduleId = this.scheduleId;
    course.name = this.name;
    course.startTime = this.startTime;
    course.duration = this.duration;
    course.type = this.type;
    course.playList = new ArrayList<>();
    for (VideoUnit unit : this.playList) {
      course.playList.add(unit.clone());
    }
    return course;
  }
}
